﻿'Musjid Display System (MDS or mdsys - for short) is a program written in VB.NET 2008. Its purpose is to display a dynamic page of information on a large screen (eg. Plasma Screen, TV, etc) situated in a Musjid, with salaah times, hadeeth, messages, etc
'    Copyright (C) 2008 Muhammed Cotwal (muhammedc_AT_gmail.com)

'    This program is free software: you can redistribute it and/or modify
'    it under the terms of the GNU General Public License as published by
'    the Free Software Foundation, either version 3 of the License, or
'    (at your option) any later version.

'    This program is distributed in the hope that it will be useful,
'    but WITHOUT ANY WARRANTY; without even the implied warranty of
'    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'    GNU General Public License for more details.

'    You should have received a copy of the GNU General Public License
'    along with this program.  If not, see <http://www.gnu.org/licenses/>.

Public Class frmScreenDisplay
    'Trap keystroke CTRL+S to bring up settings section
    Private Sub frmScreenDisplay_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.Modifiers = Keys.Control And e.KeyCode = Keys.S Then
            frmScreenSettings.Show()
        End If
    End Sub

    'Initialise form
    Private Sub frmScreenDisplay_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Temporary Debug/Development warning message and development version/exit label
        MsgBox("WARNING: This software is still in development and is not yet fit for production use!", MsgBoxStyle.Exclamation)
        If System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed Then
            lblVersion.Text = "Demo Alpha Version: " & My.Application.Deployment.CurrentVersion.ToString  'Application.ProductVersion
        Else
            lblVersion.Text = "Demo Alpha Non Deployed"
        End If
        'Check and create update folder if necessary
        CreateUpdateFolder()
        'Check if Regional Settings for Long Date and Time Format are correct
        TimeAndDateSettings()
        'Load MDS settings from DB and apply
        UpdateSettings()
    End Sub
    'Temporary Development Escape/Exit mechanism
    Private Sub lblVersion_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblVersion.Click
        End
    End Sub
    'This timer control is used to increment the realtime clock display
    Private Sub tmrClock_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrClock.Tick
        'To enable correct display of time, set your regional settings under control panel to "HH:mm:ss tt"
        lblTime.Text = Format(Now, "Long Time")
    End Sub
    'This timer control runs every 5 mins and updates necessary information
    Private Sub tmr5min_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmr5min.Tick
        UpdateSalaahTimes()
        UpdateDates()
    End Sub
    'This timer control runs every 30 mins and updates necessary information
    Private Sub tmr30min_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmr30min.Tick
        GetHadith()
    End Sub
    'This timer control runs every min and updates necessary information
    Private Sub tmr1min_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmr1min.Tick
        HighlightCurrentSalaahTime()
    End Sub
    'This timer control flipflops the warning display when activated
    Private Sub tmrWarninglbl_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrWarninglbl.Tick
        'Check if current back colour is red and flips it to white
        If lblForbiddenTimeWarning.BackColor = Color.Red Then
            lblForbiddenTimeWarning.BackColor = Color.White
            lblForbiddenTimeWarning.ForeColor = Color.Red
            Exit Sub
        End If
        'Check if current back colour is white and flops it to red
        If lblForbiddenTimeWarning.BackColor = Color.White Then
            lblForbiddenTimeWarning.BackColor = Color.Red
            lblForbiddenTimeWarning.ForeColor = Color.White
            Exit Sub
        End If
    End Sub
End Class

